from django.urls import path, include
from rest_framework.routers import DefaultRouter
from .views import NoteListCreateView, NoteDetailView, CategoryListCreateView, TagListCreateView, \
    LikeToggleView, CommentViewSet

# 使用 DefaultRouter 生成评论相关的路由
router = DefaultRouter()
router.register(r'comments', CommentViewSet, basename='comments')

urlpatterns = [
    path('notes/', NoteListCreateView.as_view(), name='note_list_create'),
    path('notes/<int:pk>/', NoteDetailView.as_view(), name='note_detail'),
    # 点赞相关的路由
    path('notes/<int:note_id>/likes/', LikeToggleView.as_view(), name='like-toggle'),
    path('category/', CategoryListCreateView.as_view(), name='category_list'),
    path('tags/', TagListCreateView.as_view(), name='tag-list-create'),
    # 包含由 router 自动生成的评论相关的路由
    path('', include(router.urls)),
]
